<%@ page import="javafx.concurrent.Worker" %><%--
  Created by IntelliJ IDEA.
  User: Reimu
  Date: 2022/5/7
  Time: 12:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>c1</title>
</head>
<body>

<%
    // 猜测目标
    int target = 0;
    if (session.getAttribute("target") == null) {
        // 产生[1, 100]之间随机整数作为猜测目标
        target = (int) (Math.random() * 100) + 1;
        // 将猜测目标随机整数存放到session里
        session.setAttribute("target", target);
    } else {
        // 从session里获取猜测目标随机整数
        target = (int) session.getAttribute("target");
    }

    // 猜测次数
    int count = 0;
    if (session.getAttribute("count") == null) {
        // 在session里创建count属性
        session.setAttribute("count", 0);
    } else {
        // 从session里取出count属性值
        count = (int) session.getAttribute("count");
    }
%>

<form action="guess.jsp" method="post" name="form">
    I'm thinking of a number between 1 and 100.<br/>
    What's your guess?
    <input type="text" name="num"><br>
    <input type="submit" value="去猜测这个数" name="submit">
</form>

</body>
</html>
